import { createRouter, createWebHistory } from 'vue-router'
import Layout from "../layout/Layout";
import Book from "../views/Book";

/*route:指的是一个路由   routes：指的是多个路由   router: 指的是路由的管理者  (如下面把routes放到了router里面，相当于router来管理routes)
* 引入组件的方式，可以使用component: Home;  也可以 component:() => import("@/views/Home")*/
const routes = [
  {
    path: '/',
    name: 'Layout',
    component: Layout,
    redirect: '/user',
    children:[
      {
        path: 'user',
        name: 'User',
        component: () => import("@/views/User")
      },

      {
        path: 'book',
        name: 'Book',
        component: Book
      },
    ]
  },
  {
    path: '/login',
    name: 'Login',
    component:() => import("@/views/Login")
  },
  {
    path: '/register',
    name: 'Register',
    component:() => import("@/views/Register")
  }
]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

export default router
